﻿using System;
using Framework.MVC;
using Identity.Model;
using Framework.MVVM.Model;
using Identity.IService;
using Identity.Service;

namespace FrontCenter.Models
{
    [ServiceAttribute(typeof(IIdentityService), typeof(IdentityService), "Instance")]
    public class DeleteIdentityModel : AsyncModelBase, IDeleteIdentity
    {
        #region Field

        private const string m_entry = "entry";

        #endregion Field

        #region AsyncModelBase

        protected override void OnInit(Type type)
        {
            OnBeginRequest();
            this.DeleteIdentity(string.Empty, string.Empty);
        }

        #endregion AsyncModelBase

        #region IDeleteIdentity

        public string IdentityCode { get; set; }

        public string IdentityResource { get; set; }

        public string Source { get; set; }

        public void OnDeleteIdentityComplete(string key, Identity.IService.Entry.IdentityEntry entry)
        {
            OnComplete(m_entry, entry);
            OnEndRequest();
        }

        public void OnDeleteIdentityError(string key)
        {
            OnEndRequest();
        }

        #endregion IDeleteIdentity
    }
}